

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Causal Discovery Toolbox Documentation &mdash; Causal Discovery Toolbox 0.5.22 documentation</title>
  

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="_static/favicon.png"/>
  
  
  

  
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
        <script type="text/x-mathjax-config">MathJax.Hub.Config({"extensions": ["tex2jax.js"], "jax": ["input/TeX", "output/HTML-CSS"], "tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "displayMath": [["$$", "$$"], ["\\[", "\\]"]], "processEscapes": true}, "HTML-CSS": {"fonts": ["TeX"]}})</script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Get started" href="tutorial.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="#">
          

          
            
            <img src="_static/banner.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
              <div class="version">
                0.5.22
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Causal Discovery Toolbox Documentation</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="tutorial.html">Get started</a></li>
<li class="toctree-l1"><a class="reference internal" href="causality.html">cdt.causality</a></li>
<li class="toctree-l1"><a class="reference internal" href="independence.html">cdt.independence</a></li>
<li class="toctree-l1"><a class="reference internal" href="data.html">cdt.data</a></li>
<li class="toctree-l1"><a class="reference internal" href="utils.html">cdt.utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="metrics.html">cdt.metrics</a></li>
<li class="toctree-l1"><a class="reference internal" href="settings.html">Toolbox Settings</a></li>
<li class="toctree-l1"><a class="reference internal" href="models.html">PyTorch Models</a></li>
<li class="toctree-l1"><a class="reference internal" href="developer.html">Developer Documentation</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="#">Causal Discovery Toolbox</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="#" class="icon icon-home"></a> &raquo;</li>
        
      <li>Causal Discovery Toolbox Documentation</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <img alt="_images/banner.png" src="_images/banner.png" />
<p><span class="raw-html"><br /></span></p>
<div class="section" id="causal-discovery-toolbox-documentation">
<h1>Causal Discovery Toolbox Documentation<a class="headerlink" href="#causal-discovery-toolbox-documentation" title="Permalink to this headline">¶</a></h1>
<p>Package for causal inference in graphs and in the pairwise settings for Python&gt;=3.5. Tools for graph structure recovery and dependencies are included. The package is based on Numpy, Scikit-learn, Pytorch and R.</p>
<a class="reference external image-reference" href="https://travis-ci.org/FenTechSolutions/CausalDiscoveryToolbox"><img alt="https://travis-ci.org/FenTechSolutions/CausalDiscoveryToolbox.svg?branch=master" src="https://travis-ci.org/FenTechSolutions/CausalDiscoveryToolbox.svg?branch=master" /></a>
<a class="reference external image-reference" href="https://travis-ci.org/FenTechSolutions/CausalDiscoveryToolbox"><img alt="https://travis-ci.org/FenTechSolutions/CausalDiscoveryToolbox.svg?branch=dev" src="https://travis-ci.org/FenTechSolutions/CausalDiscoveryToolbox.svg?branch=dev" /></a>
<a class="reference external image-reference" href="https://codecov.io/gh/FenTechSolutions/CausalDiscoveryToolbox"><img alt="https://codecov.io/gh/FenTechSolutions/CausalDiscoveryToolbox/branch/master/graph/badge.svg" src="https://codecov.io/gh/FenTechSolutions/CausalDiscoveryToolbox/branch/master/graph/badge.svg" /></a>
<img alt="https://img.shields.io/aur/license/pac.svg?maxAge=259200" src="https://img.shields.io/aur/license/pac.svg?maxAge=259200" />
<img alt="https://img.shields.io/badge/version-0.5.22-yellow.svg?maxAge=259200" src="https://img.shields.io/badge/version-0.5.22-yellow.svg?maxAge=259200" />
<p>It implements lots of algorithms for graph structure recovery (including algorithms from the <cite>bnlearn</cite>, <cite>pcalg</cite> packages), mainly based out of observational data.</p>
<p>Install it using pip: (See more details on installation below)</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pip install cdt
</pre></div>
</div>
</div>
<div class="section" id="open-source-project">
<h1>Open-source project<a class="headerlink" href="#open-source-project" title="Permalink to this headline">¶</a></h1>
<p>The package is open-source and under the MIT license, the source code is
available at : <a class="reference external" href="https://github.com/FenTechSolutions/CausalDiscoveryToolbox">https://github.com/FenTechSolutions/CausalDiscoveryToolbox</a></p>
<p>When using this package, please cite: <a class="reference external" href="https://arxiv.org/abs/1903.02278">Kalainathan, D., &amp; Goudet, O. (2019).
Causal Discovery Toolbox: Uncover causal relationships in Python.
arXiv:1903.02278</a>.</p>
</div>
<div class="section" id="docker-images">
<h1>Docker images<a class="headerlink" href="#docker-images" title="Permalink to this headline">¶</a></h1>
<p>Docker images are available, including all the dependencies, and enabled functionalities:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 48%" />
<col style="width: 23%" />
<col style="width: 30%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Branch</p></th>
<th class="head"><p>master</p></th>
<th class="head"><p>dev</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Python 3.6 - CPU</p></td>
<td><p><a class="reference external" href="https://hub.docker.com/r/divkal/cdt-py3.6/"><img alt="36cpu" src="https://img.shields.io/badge/docker-0.5.22-0db7ed.svg?maxAge=259200" /></a></p></td>
<td><p><a class="reference external" href="https://hub.docker.com/r/divkal/cdt-dev/"><img alt="36cpudev" src="https://img.shields.io/badge/docker-latest-0db7ed.svg?maxAge=259200" /></a></p></td>
</tr>
<tr class="row-odd"><td><p>Python 3.7 - CPU</p></td>
<td><p><a class="reference external" href="https://hub.docker.com/r/divkal/cdt-py3.7/"><img alt="37cpu" src="https://img.shields.io/badge/docker-0.5.22-0db7ed.svg?maxAge=259200" /></a></p></td>
<td><p><img alt="37cpudev" src="https://img.shields.io/badge/docker-unavailable-lightgrey.svg?maxAge=259200" /></p></td>
</tr>
<tr class="row-even"><td><p>Python 3.6 - GPU</p></td>
<td><p><a class="reference external" href="https://hub.docker.com/r/divkal/nv-cdt-py3.6/"><img alt="36gpu" src="https://img.shields.io/badge/nvidia--docker-0.5.22-76b900.svg?maxAge=259200" /></a></p></td>
<td><p><a class="reference external" href="https://hub.docker.com/r/divkal/nv-cdt-dev/"><img alt="36gpudev" src="https://img.shields.io/badge/nvidia--docker-latest-76b900.svg?maxAge=259200" /></a></p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h1>
<p>The packages requires a python version &gt;=3.5, as well as some libraries listed
in the <a class="reference external" href="https://github.com/FenTechSolutions/CausalDiscoveryToolbox/blob/master/requirements.txt">requirements file</a>.
For some additional functionalities, more libraries are needed for these extra
functions and options to become available. Here is a quick install guide of the
package, starting off with the minimal install up to the full installation.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>A (mini/ana)conda framework would help installing all those packages and therefore could be recommended for non-expert users.</p>
</div>
<div class="section" id="pytorch">
<h2>PyTorch<a class="headerlink" href="#pytorch" title="Permalink to this headline">¶</a></h2>
<p>As some of the key algorithms in the _cdt_ package use the PyTorch package, it is required to install it.
Check out their website to install the PyTorch version suited to your hardware configuration: <a class="reference external" href="https://pytorch.org">https://pytorch.org</a></p>
</div>
<div class="section" id="install-the-causaldiscoverytoolbox-package">
<h2>Install the CausalDiscoveryToolbox package<a class="headerlink" href="#install-the-causaldiscoverytoolbox-package" title="Permalink to this headline">¶</a></h2>
<p>The package is available on PyPi:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pip install cdt
</pre></div>
</div>
<p>Or you can also install it from source.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ git clone https://github.com/FenTechSolutions/CausalDiscoveryToolbox.git  <span class="c1"># Download the package</span>
$ <span class="nb">cd</span> CausalDiscoveryToolbox
$ pip install -r requirements.txt  <span class="c1"># Install the requirements</span>
$ python setup.py install develop --user
</pre></div>
</div>
<p><strong>The package is then up and running ! You can run most of the algorithms in the CausalDiscoveryToolbox, you might get warnings: some additional features are not available</strong></p>
<p>From now on, you can import the library using :</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">cdt</span>
</pre></div>
</div>
</div>
<div class="section" id="additional-r-and-r-libraries">
<h2>Additional : R and R libraries<a class="headerlink" href="#additional-r-and-r-libraries" title="Permalink to this headline">¶</a></h2>
<p>In order to have access to additional algorithms from various R packages such as bnlearn, kpcalg, pcalg, … while using the _cdt_ framework, it is required to install R.</p>
<p>Check out how to install all R dependencies in the before-install section of the [travis.yml](<a class="reference external" href="https://github.com/FenTechSolutions/CausalDiscoveryToolbox/blob/master/.travis.yml">https://github.com/FenTechSolutions/CausalDiscoveryToolbox/blob/master/.travis.yml</a>) file for debian based distributions.
The <a class="reference external" href="https://github.com/FenTechSolutions/CausalDiscoveryToolbox/blob/master/r_requirements.txt">r-requirements file</a> notes all the R packages used by the toolbox.</p>
</div>
</div>
<div class="section" id="overview">
<h1>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h1>
<p>The following figure shows how the package and its algorithms are structured:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>cdt package
|
|- independence
|  |- graph (Infering the skeleton from data)
|  |  |- Lasso variants (Randomized Lasso[1], Glasso[2], HSICLasso[3])
|  |  |- FSGNN (CGNN[12] variant for feature selection)
|  |  |- Skeleton recovery using feature selection algorithms (RFECV[5], LinearSVR[6], RRelief[7], ARD[8,9], DecisionTree)
|  |
|  |- stats (pairwise methods for dependency)
|     |- Correlation (Pearson, Spearman, KendallTau)
|     |- Kernel based (NormalizedHSIC[10])
|     |- Mutual information based (MIRegression, Adjusted Mutual Information[11], Normalized mutual information[11])
|
|- data
|  |- CausalPairGenerator (Generate causal pairs)
|  |- AcyclicGraphGenerator (Generate FCM-based graphs)
|  |- load_dataset (load standard benchmark datasets)
|
|- causality
|  |- graph (methods for graph inference)
|  |  |- CGNN[12]
|  |  |- PC[13]
|  |  |- GES[13]
|  |  |- GIES[13]
|  |  |- LiNGAM[13]
|  |  |- CAM[13]
|  |  |- GS[23]
|  |  |- IAMB[24]
|  |  |- MMPC[25]
|  |  |- SAM[26]
|  |  |- CCDr[27]
|  |
|  |- pairwise (methods for pairwise inference)
|     |- ANM[14] (Additive Noise Model)
|     |- IGCI[15] (Information Geometric Causal Inference)
|     |- RCC[16] (Randomized Causation Coefficient)
|     |- NCC[17] (Neural Causation Coefficient)
|     |- GNN[12] (Generative Neural Network -- Part of CGNN )
|     |- Bivariate fit (Baseline method of regression)
|     |- Jarfo[20]
|     |- CDS[20]
|     |- RECI[28]
|
|- metrics (Implements the metrics for graph scoring)
|  |- Precision Recall
|  |- SHD
|  |- SID [29]
|
|- utils
   |- Settings -&gt; SETTINGS class (hardware settings)
   |- loss -&gt; MMD loss [21, 22] &amp; various other loss functions
   |- io -&gt; for importing data formats
   |- graph -&gt; graph utilities
</pre></div>
</div>
</div>
<div class="section" id="references">
<h1>References<a class="headerlink" href="#references" title="Permalink to this headline">¶</a></h1>
<ul class="simple">
<li><p>[1] Wang, S., Nan, B., Rosset, S., &amp; Zhu, J. (2011). Random lasso. The annals of applied statistics, 5(1), 468.</p></li>
<li><p>[2] Friedman, J., Hastie, T., &amp; Tibshirani, R. (2008). Sparse inverse covariance estimation with the graphical lasso. Biostatistics, 9(3), 432-441.</p></li>
<li><p>[3] Yamada, M., Jitkrittum, W., Sigal, L., Xing, E. P., &amp; Sugiyama, M. (2014). High-dimensional feature selection by feature-wise kernelized lasso. Neural computation, 26(1), 185-207.</p></li>
<li><p>[4] Feizi, S., Marbach, D., Médard, M., &amp; Kellis, M. (2013). Network deconvolution as a general method to distinguish direct dependencies in networks. Nature biotechnology, 31(8), 726-733.</p></li>
<li><p>[5] Guyon, I., Weston, J., Barnhill, S., &amp; Vapnik, V. (2002). Gene selection for cancer classification using support vector machines. Machine learning, 46(1), 389-422.</p></li>
<li><p>[6] Vapnik, V., Golowich, S. E., &amp; Smola, A. J. (1997). Support vector method for function approximation, regression estimation and signal processing. In Advances in neural information processing systems (pp. 281-287).</p></li>
<li><p>[7] Kira, K., &amp; Rendell, L. A. (1992, July). The feature selection problem: Traditional methods and a new algorithm. In Aaai (Vol. 2, pp. 129-134).</p></li>
<li><p>[8] MacKay,  D.  J.  (1992). Bayesian interpolation. Neural Computation, 4, 415–447.</p></li>
<li><p>[9] Neal, R. M. (1996). Bayesian learning for neural networks. No. 118 in Lecture Notes in Statistics. New York: Springer.</p></li>
<li><p>[10] Gretton, A., Bousquet, O., Smola, A., &amp; Scholkopf, B. (2005, October). Measuring statistical dependence with Hilbert-Schmidt norms. In ALT (Vol. 16, pp. 63-78).</p></li>
<li><p>[11] Vinh, N. X., Epps, J., &amp; Bailey, J. (2010). Information theoretic measures for clusterings comparison: Variants, properties, normalization and correction for chance. Journal of Machine Learning Research, 11(Oct), 2837-2854.</p></li>
<li><p>[12] Goudet, O., Kalainathan, D., Caillou, P., Lopez-Paz, D., Guyon, I., Sebag, M., … &amp; Tubaro, P. (2017). Learning functional causal models with generative neural networks. arXiv preprint arXiv:1709.05321.</p></li>
<li><p>[13] Spirtes, P., Glymour, C., Scheines, R. (2000). Causation, Prediction, and Search. MIT press.</p></li>
<li><p>[14] Hoyer, P. O., Janzing, D., Mooij, J. M., Peters, J., &amp; Schölkopf, B. (2009). Nonlinear causal discovery with additive noise models. In Advances in neural information processing systems (pp. 689-696).</p></li>
<li><p>[15] Janzing, D., Mooij, J., Zhang, K., Lemeire, J., Zscheischler, J., Daniušis, P., … &amp; Schölkopf, B. (2012). Information-geometric approach to inferring causal directions. Artificial Intelligence, 182, 1-31.</p></li>
<li><p>[16] Lopez-Paz, D., Muandet, K., Schölkopf, B., &amp; Tolstikhin, I. (2015, June). Towards a learning theory of cause-effect inference. In International Conference on Machine Learning (pp. 1452-1461).</p></li>
<li><p>[17] Lopez-Paz, D., Nishihara, R., Chintala, S., Schölkopf, B., &amp; Bottou, L. (2017, July). Discovering causal signals in images. In Proceedings of CVPR.</p></li>
<li><p>[18] Stegle, O., Janzing, D., Zhang, K., Mooij, J. M., &amp; Schölkopf, B. (2010). Probabilistic latent variable models for distinguishing between cause and effect. In Advances in Neural Information Processing Systems (pp. 1687-1695).</p></li>
<li><p>[19] Zhang, K., &amp; Hyvärinen, A. (2009, June). On the identifiability of the post-nonlinear causal model. In Proceedings of the twenty-fifth conference on uncertainty in artificial intelligence (pp. 647-655). AUAI Press.</p></li>
<li><p>[20] Fonollosa, J. A. (2016). Conditional distribution variability measures for causality detection. arXiv preprint arXiv:1601.06680.</p></li>
<li><p>[21] Gretton, A., Borgwardt, K. M., Rasch, M. J., Schölkopf, B., &amp; Smola, A. (2012). A kernel two-sample test. Journal of Machine Learning Research, 13(Mar), 723-773.</p></li>
<li><p>[22] Li, Y., Swersky, K., &amp; Zemel, R. (2015). Generative moment matching networks. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15) (pp. 1718-1727).</p></li>
<li><p>[23] Margaritis D (2003). Learning Bayesian Network Model Structure from Data . Ph.D. thesis, School of Computer Science, Carnegie-Mellon University, Pittsburgh, PA. Available as Technical Report CMU-CS-03-153</p></li>
<li><p>[24] Tsamardinos I, Aliferis CF, Statnikov A (2003). “Algorithms for Large Scale Markov Blanket Discovery”. In “Proceedings of the Sixteenth International Florida Artificial Intelligence Research Society Conference”, pp. 376-381. AAAI Press.</p></li>
<li><p>[25] Tsamardinos I, Aliferis CF, Statnikov A (2003). “Time and Sample Efficient Discovery of Markov Blankets and Direct Causal Relations”. In “KDD ’03: Proceedings of the Ninth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining”, pp. 673-678. ACM. Tsamardinos I, Brown LE, Aliferis CF (2006). “The Max-Min Hill-Climbing Bayesian Network Structure Learning Algorithm”. Machine Learning,65(1), 31-78.</p></li>
<li><p>[26] Kalainathan, Diviyan &amp; Goudet, Olivier &amp; Guyon, Isabelle &amp; Lopez-Paz, David &amp; Sebag, Michèle. (2018). SAM: Structural Agnostic Model, Causal Discovery and Penalized Adversarial Learning.</p></li>
<li><p>[27] Aragam, B., &amp; Zhou, Q. (2015). Concave penalized estimation of sparse Gaussian Bayesian networks. Journal of Machine Learning Research, 16, 2273-2328.</p></li>
<li><p>[28] Bloebaum, P., Janzing, D., Washio, T., Shimizu, S., &amp; Schoelkopf, B. (2018, March). Cause-Effect Inference by Comparing Regression Errors. In International Conference on Artificial Intelligence and Statistics (pp. 900-909).</p></li>
<li><p>[29] Structural Intervention Distance (SID) for Evaluating Causal Graphs, Jonas Peters, Peter Bühlmann: <a class="reference external" href="https://arxiv.org/abs/1306.1043">https://arxiv.org/abs/1306.1043</a></p></li>
</ul>
<div class="toctree-wrapper compound">
</div>
<div class="toctree-wrapper compound">
</div>
</div>
<div class="section" id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
<p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p>
<p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p>
<p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="tutorial.html" class="btn btn-neutral float-right" title="Get started" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        
        &copy; Copyright 2018, Diviyan Kalainathan, Olivier Goudet

    </p>
  </div>
    
    
    
    Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>